import QtQuick
import QtQuick.Controls
import Qt5Compat.GraphicalEffects

Item {

    Flow {

        anchors.fill: parent
        spacing: 10
        padding: 10

        Rectangle {
            width: 280
            height: 280
            color: "white"

            Image {
                id: img
                source: "qrc:/images/bug.jpg"
                sourceSize: Qt.size(parent.width, parent.height)
                smooth: true
                visible: false
            }

            Rectangle {
                id: rect_displace
                color: "#8080FF"
                anchors.fill: parent
                visible: false
                Image {
                    anchors.centerIn: parent
                    source: "qrc:/images/glass_normal.png"
                    sourceSize: Qt.size(parent.width/2, parent.height/2)
                    smooth: true
                }
            }

            Displace {
                id: displace
                anchors.fill: img
                source: img
                displacementSource: rect_displace
                displacement: 0.1
            }

            Row {
                anchors.bottom: parent.bottom
                Text { text: "displacement:"}
                Slider {
                    from: -1
                    to: 1
                    stepSize: 0.1
                    value: 0.1

                    onValueChanged: {
                        displace.displacement = value
                    }
                }
            }
        }
    }
}
